package com.eastedu.report.common.model.parameter;

import com.eastedu.common.enums.DateCodeType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.constraints.Pattern;
import java.util.Objects;

/**
 * The type Report export parameter.
 *
 * @author superman
 */
@Data
public class ReportExportParameter {
    @Schema(description = "校级ID")
    private Long schoolGroupId;
    @Schema(description = "学校GUID")
    private String schoolGuid;
    @Schema(description = "学段")
    private String section;
    @Schema(description = "日期编码类型")
    private DateCodeType codeType;
    @Schema(description = "导出日期编码")
    @Pattern(regexp = "^2[0-9]{5}$", message = "日期编码格式错误, 日期编码格式为202305")
    private Integer dateCode;

    @Schema(description = "是否开启调试模式")
    private boolean debug;

    /**
     * 如果为空，默认为月份（不要删除该方法，否则出现数据紊乱）
     *
     * @return the code type
     */
    public DateCodeType getCodeType() {
        if (Objects.isNull(this.codeType)) {
            return DateCodeType.MONTH;
        }
        return codeType;
    }

    /**
     * 如果为空，默认为当前月份（不要删除该方法，否则出现数据紊乱）
     *
     * @return the date code
     */
    public Integer getDateCode() {
        if (Objects.isNull(this.dateCode)) {
            return getCodeType().getLast();
        }
        return dateCode;
    }

}
